package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.service.NursingProjectServies;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目")
public class NursingProjectController {

    @Autowired
    private NursingProjectServies nursingProjectServies;

    //   分页查询
    @GetMapping
    public ResponseResult<PageResponse<NursingProjectVo>> getNursingProject(
            @ApiParam(value = "护理项目名称") String name,
            @ApiParam(value = "当前页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页展示条数") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @ApiParam(value = "状态") Integer status
    ) {
        PageResponse<NursingProjectVo> projectVoPageResponse = nursingProjectServies.getNursingProject(name, pageNum, pageSize, status);
        return ResponseResult.success(projectVoPageResponse);
    }

    //删除
    @DeleteMapping("/{id}")
    public ResponseResult deleteNursingProject(@ApiParam(value = "护理项目id",required = true)@PathVariable  Long id) {
        nursingProjectServies.deleteNursingProject(id);
        return ResponseResult.success();
     }

     //禁用
     @PutMapping("/{id}/status/{status}")
     public ResponseResult disableNursingProject(@ApiParam(value = "护理项目id",required = true)@PathVariable  Long id, @ApiParam(value = "状态",required = true)@PathVariable  Integer status) {
        nursingProjectServies.disableNursingProject(id, status);
        return ResponseResult.success();
     }
     //新增
     @PostMapping
     public ResponseResult addNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectServies.addNursingProject(nursingProjectDto);
        return ResponseResult.success();
     }
     //回显，根据id查询护理
     @GetMapping("/{id}")
     public ResponseResult<NursingProjectVo> getNursingProject(@ApiParam(value = "护理项目id",required = true)@PathVariable  Long id) {
         NursingProjectVo pageResponse=nursingProjectServies.echoNursingProject(id);
        return ResponseResult.success(pageResponse);
     }
     //修改
     @PutMapping
    public ResponseResult updateNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectServies.updateNursingProject(nursingProjectDto);
        return ResponseResult.success();
     }



}